<%
//--------------------------------------------------------------------------------->
//
// Copyright 2002 e Professional Corporation.  All Rights Reserved.
//
// File:       	CFHAADMT04.jsp
//
// Author:   	MAX
//
// Start Date:	20/12/2547
//
// Finish Date: XX/XX/XXXX 
//
// Update Date : xx/xx/xxxx by Who
// ............????????..........
//
// Update Date : xx/xx/xxxx by Who
// ......................
//
//--------------------------------------------------------------------------------->
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%//@ include file="../include/eproAuthorization.jsp"%>
<%@ page 
               	import="com.epro.standard.usermenu.UserAccountVO,
                                   com.epro.standard.frontend.util.FileInfoUtil,
                                   com.epro.standard.frontend.util.EproServletUtil,
                                   com.epro.standard.frontend.util.ShowData,
                                   java.util.Vector, com.softplus.carrefour.hd.CFHDSystem,
                                   com.softplus.carrefour.hd.bltier.admin.UserOfficeHourManage,
                                   com.softplus.carrefour.hd.bltier.entity.UserOfficeHour,
                                   com.softplus.carrefour.hd.bltier.entity.UserLevel,
                                   org.displaytag.tags.TableTag,
                                   org.displaytag.tags.TableTagExtraInfo"
     %>
<html xmlns:epro>
<%@ taglib uri="/WEB-INF/displaytag-12.tld" prefix="display"%>
<%@ taglib uri="/WEB-INF/DynamicMasterTag.tld" prefix="dynamicmaster"%>
<%@ taglib uri="/WEB-INF/ViewTableTag.tld" prefix="view"%>
<%@ taglib uri="/WEB-INF/HeadTag.tld" prefix="head"%>
<%@ taglib uri="/WEB-INF/MasterTag.tld" prefix="master"%>
<%@ taglib uri="/WEB-INF/ToolbarTag.tld" prefix="toolbar"%>
<%@ taglib uri="/WEB-INF/NavigateBarTag.tld" prefix="navigate"%>
<%@ taglib uri="/WEB-INF/HintTag.tld" prefix="hint"%>
<%@ taglib uri="/WEB-INF/ErrorTag.tld" prefix="error"%>
<head:Head
	author		="MAX"
	title			="User's Office Hour(s) Setup"
	import		="masterTable,toolbar,navigateBar,hint,error,viewtable"
	styleFile	="../theme/defaultTheme.css,../theme/CFRLTheme.css"
	jsFile			="../script/spTitleRefresh.js,../script/imgProp.js,../script/Alert.js,../script/showHints.js,../script/masterTable.js">
</head:Head>	
<%
  
      java.util.Date startDate = new java.util.Date() ;
	ShowData showData      = new ShowData();
	
//********************* define variable **************************
	FileInfoUtil	fileInfoUtil 	= session.getAttribute("fileInfoUtil")!=null?(FileInfoUtil)session.getAttribute("fileInfoUtil"):new FileInfoUtil() ;
  fileInfoUtil.setMenuIDCode("CFHDADMT04 ") ;
  fileInfoUtil.setMenuName("User's Office Hour(s) Setup") ;
  fileInfoUtil.setMenuDesc("To setup user's office hour(s)") ;
  fileInfoUtil.setMasterWording("User's Office Hour(s)") ;
//  session.setAttribute("fileInfoUtil", fileInfoUtil) ;
//	String menuIDCode	      				= fileInfoUtil.getMenuIDCode();
//	EproServletUtil 	servletUtil	  = new EproServletUtil(request);
//	DecimalFormat df  =  new DecimalFormat("0"); 
//	com.epro.standard.frontend.util.StringUtil stringUtil = new com.epro.standard.frontend.util.StringUtil();
//-------------------------------------------------------

//  String 				FromMD				    = request.getParameter("FromMD") == null ? "" : request.getParameter("FromMD");
//  ArrayList     arraylist					=(ArrayList)session.getAttribute("ArrayListFromServlet");
// 	session.removeAttribute("ArrayListFromServlet");
//  session.setAttribute("ArrayListFromServlet2",arraylist);
//  
//  String				isConfrimData	= request.getParameter("isConfrimData") == null ? "" : request.getParameter("isConfrimData");
//-------------------------------------------------------
// define variable for MasterTag *********
  String userID               = request.getParameter("uid")!=null?request.getParameter("uid"):(String)session.getAttribute("userIDHDADMT04");
  System.out.println("user id>"+userID+"<");
  session.setAttribute("userIDHDADMT04", userID) ;
  session.setAttribute("titleInsert", "User's Office Hour(s) Setup : Add New") ;
  session.setAttribute("titleUpdate", "User's Office Hour(s) Setup : Update") ;
  String linkParameter				= "?";
//	String detailWidth 					= "40";
//	String detailHeight 				= "20";
  String insertURL            = "CFHDADIN04.jsp" ;
  String insertOnclick        = "showModalDialog('CFHDADFM.jsp?pageName=" + insertURL + "', window, 'help=no;status=no;dialogWidth=600px;dialogHeight=400px;scrollbar=no');" ;
	String updateURL					  = "CFHDADUP04.jsp" ; //fileInfoUtil.getUpdateURL()+ linkParameter;
  String updateOnclickFirst   = "showModalDialog('CFHDADFM.jsp?pageName=" + updateURL + "&index=" ;
  String updateOnclickLast    = "', window, 'help=no;status=no;dialogWidth=600px;dialogHeight=450px;scrollbar=no');" ;
	String deleteURL						= "" ; //fileInfoUtil.getServletURL()+ linkParameter+"&action=delete";
	String detailURL 						= "CFHDADDT04.jsp" ; //fileInfoUtil.getDetailURL()+ linkParameter;
  String detailOnclickFirst   = "showModalDialog('CFHDADFM.jsp?pageName=" + detailURL + "&index=" ;
  String detailOnclickLast    = "', window, 'help=no;status=no;dialogWidth=600px;dialogHeight=450px;scrollbar=no');" ;
	String queryURL						  = "CFHDADMT04.jsp?uid=" + userID ; //fileInfoUtil.getMasterURL()+linkParameter;
	String qureyOnclick					= "window.location.href = '" + queryURL +"'";
	String backURL						  = "/CFRL/CFRLWEBMN01.jsp?page=1" ; //request.getContextPath() + "/CFRLWEBMN01.jsp?page=1" ;
//	String backClick						= fileInfoUtil.getHasParent()+"parent.window.location.href('" + backURL +linkParameter+"')";
	String backClick						= "showProcessLayer(); location='" + backURL + "'" ; //"parent.window.location.href('" + backURL +linkParameter+"')";
// *********************************************
	String 	masterWidth 				=	"700"; //755
	String	masterHeight 			  =	"240";
  boolean pageComplete        = false ;

// --------------------------- Display master zone ----------------------------------
  UserOfficeHourManage ohm = (UserOfficeHourManage)CFHDSystem.getControlClass("USER_OFFICE_HOUR") ;
  Vector dataVector = ohm.getAllUserOfficeHour() ;
  session.setAttribute("OfficeHourManagerVector",dataVector) ;
  request.setAttribute("officeHourTable", dataVector) ;
  UserLevel ul = new UserLevel() ;
// ----------------------------------------------------------------------------------
%>
<%@ include file="../include/toolbarHint.jsp"%>
<body onload="recoveryPage(document.all.officeHourTable);">
<div id="processingLayer" style="visibility:hidden; position:absolute; left:90px; top:80px;">
    <img src="../images/background/Processing.gif" width=585 height="136" border="0" />
</div>
<script  type="text/javascript">

    function submitForm()
  	{
      if (checkBeforeDelete('deleteCheck'))
      {
        if (showOConfirmDialog('Confirm','Confirm Delete','OK','Cancel') == 1)
          frm.submit() ;
        <%//@include file="../include/eproSaveFormSubmit.jsp"%>
      }
      else
        showOErrorDialog('Error','No row selected for delete','OK')
    }
    
    function recoveryPage(displayTable)
    {
      try {
        if(document.all.tableContainer.innerText=='')
          location.href = location.href.indexOf('?')>0?location.href+'&pageError=true':'?pageError=true' ;
        else if((displayTable!=undefined)||(displayTable!=null))
          if (displayTable.children[1].children[0].children.length != 5)
             <%=qureyOnclick%> ;
  //location.reload() ;
  //          location.href = location.href.replace('&pageError=true') ;
  //          location.href.indexOf('&pageError=true')>0?location.href+'&pageError=true':'?pageError=true' ;
  //      else
  //      {
  //      }
      } catch(error)
      {
      }
    }
   
        function showProcessLayer(){
            try{
                    document.all.programLayer.style.visibility='hidden';
                    document.all.processingLayer.style.visibility='visible';
               }catch(error){}
        }
</script>
  <form name="frm" action="../servlet/com.softplus.carrefour.hd.frontend.servlet.administration.CFHDAD04" method="post" onsubmit="submitForm();return false;">
    <input type="hidden" name="action" value="delete" />
       <div style="width:<%=masterWidth%>px;height:<%= masterHeight %>px;margin:5px" id="programLayer">
        <%=fileInfoUtil.MasterHeadTable()%>
				<table width="99%" border="0">
					<tr>
						<td class="borderFontColor">		<!-- TOOL BAR -->
                              <span style="width:100pt;">&nbsp;</span>
                <img alt="<%=backHint%>" src="../images/icon/toolbar/nBackToMenu.gif" onmouseover="this.src='../images/icon/toolbar/oBackToMenu.gif'" onmouseout="this.src='../images/icon/toolbar/nBackToMenu.gif'" style="cursor:hand" onclick="<%=backClick%>">
                <img alt="<%=insertHint%>" src="../images/icon/toolbar/nAdd.gif" onmouseover="this.src='../images/icon/toolbar/oAdd.gif'" onmouseout="this.src='../images/icon/toolbar/nAdd.gif'" style="cursor:hand" onclick="<%=insertOnclick%>">
						<%  if(dataVector.size() > 0) {%>
                  <img alt="<%=deleteHint%>" src="../images/icon/toolbar/nDelete.gif" onmouseover="this.src='../images/icon/toolbar/oDelete.gif'" onmouseout="this.src='../images/icon/toolbar/nDelete.gif'" style="cursor:hand" onclick="submitForm();">
						<% } %>
						<%=fileInfoUtil.MasterWording()%>
						</td>
					</tr>
					<tr>
						<td height="<%=masterHeight%>" valign="top" align="center" >		<!-- MASTER DATA -->
            <!-- vertical scroll -->
            <div style="height:370px" class="tableContainer"  id="tableContainer">
            <%
              try {
            %>
                    <display:table  name="officeHourTable" id="officeHourTable" styleClass="scrollTable" cellspacing="0"  width="99%" align="center" >
                    <display:column title="<input type=\"checkbox\" name=\"deleteCheckAll\" alt=\"select \ unselect all\" onclick=\"checkAllBox('deleteCheck')\" >" nowrap="yes" headerStyleClass=" fixedHeader" styleClass="scrollContent">
                   <input type="checkbox" value="<%= ((UserOfficeHour)officeHourTable).getComp_id().getUlevel() + "|" + ((UserOfficeHour)officeHourTable).getCountry().getCountryId() %>" name="deleteCheck" onclick="checkEachBox('deleteCheck','deleteCheckAll')">
                    </display:column>

                    <display:column title="Country Name" nowrap="yes" sortable="true" headerStyleClass=" fixedHeader" styleClass="scrollContent"><%= ((UserOfficeHour)officeHourTable).getCountry().getCountryName() %></display:column>

                    <display:column title="User Level" nowrap="yes" sortable="true" headerStyleClass=" fixedHeader" styleClass="scrollContent"><%= ul.getLevelName(((UserOfficeHour)officeHourTable).getComp_id().getUlevel()) %></display:column>

                    <display:column title="Updated data" nowrap="yes" sortable="true" headerStyleClass="fixedHeader" styleClass="scrollContent"><%= showData.CheckNull(((UserOfficeHour)officeHourTable).getCredDate(), "dd/MM/yyyy") %></display:column>

                    <display:column title="&nbsp;" nowrap="yes" headerStyleClass=" fixedHeader" styleClass="scrollContent">
                       <img alt="Detail" style="cursor:hand" src="../images/icon/toolbar/nDetail.gif" 
                         onmouseover="Javascript: this.src='../images/icon/toolbar/oDetail.gif' " 
                         onmouseout="Javascript: this.src='../images/icon/toolbar/nDetail.gif' " 
                         onclick="Javascript: <%= detailOnclickFirst + pageContext.getAttribute("officeHourTable_rowNum") + detailOnclickLast %>"/>
                       <img alt="<%=editHint%>" style="cursor:hand" src="../images/icon/toolbar/nEdit.gif" 
                        onmouseover="Javascript: this.src='../images/icon/toolbar/oEdit.gif' " 
                        onmouseout="Javascript: this.src='../images/icon/toolbar/nEdit.gif' "
                        onclick="Javascript: <%= updateOnclickFirst + pageContext.getAttribute("officeHourTable_rowNum") + updateOnclickLast %>"/>
                    </display:column>
                  </display:table>
        			<%
                              pageComplete = true & (request.getParameter("pageError")==null) ;
                } catch(Exception e) {
                  %>
                    <script type="text/javascript">
                        window.location.reload() ;
                    </script>
                  <%
                }
              %>
              </div>
						</td>
					</tr>
				</table>
        
<%=fileInfoUtil.MasterFootTable()%>
    </div>
  </form>
</body>
</html>
<%
  if (pageComplete)
  {
%>
<%@ include file="../include/eproErrorAlert.jsp"%>
<%}%>
